package com.bsj.travel.device;

import com.bsj.travel.constant.SecurityConstants;
import com.bsj.travel.constant.ServiceNameConstants;
import com.bsj.travel.def.common.DO.ProductDO;
import com.bsj.travel.def.common.DO.ProductTopicDO;
import com.bsj.travel.def.global.JsonResult;
import com.bsj.travel.device.factory.RemoteProductFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author yinhao
 * @version 1.0
 * @description 产品-设备服务
 * @date 2023/11/23
 */
@FeignClient(contextId = "remoteProductService", value = ServiceNameConstants.PRODUCT_DEVICE_SERVICE, fallbackFactory = RemoteProductFallbackFactory.class)
public interface RemoteProductService {

    /**
     * 新增产品
     *
     * @param productDO
     * @return
     */
    @PostMapping(value = "/product/add")
    JsonResult add(@RequestBody ProductDO productDO);

    /**
     * 获取产品列表
     *
     * @param type   1查所有 2查当前登录用户所有
     * @param source 写入inner 代表内部请求
     * @return
     */
    @GetMapping(value = "/product/list/{type}")
    JsonResult<List<ProductDO>> list(@PathVariable("type") Integer type, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 删除产品信息
     *
     * @param productId
     * @return
     */
    @PostMapping(value = "/product/delete")
    JsonResult delete(Long productId);

    /**
     * 获取对应产品的所有主题数据
     *
     * @param productKey 产品KEY
     * @param source     写入inner 代表内部请求
     * @return
     */
    @GetMapping(value = "/product/topic/getAllList/{productKey}")
    JsonResult<List<ProductTopicDO>> getAllList(@PathVariable("productKey") String productKey,
                                                @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
